package com.zhoutao.blog.seven.model.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

public enum TagColor {

    MAGENTA("magenta"),
    RED("red"),
    VOLCANO("volcano"),
    ORANGE("orange"),
    GOLD("gold"),
    LIME("lime"),
    GREEN("green"),
    CYAN("#0088EE"),
    BLUE("blue"),
    GEEK_BLUE("geekblue"),
    PURPLE("purple");

    private static Map<Integer, TagColor> colorMap = new HashMap<>();

    static {
        for (TagColor value : values()) {
            colorMap.put(value.ordinal(), value);
        }
    }

    @Getter
    private final String value;

    TagColor(String value) {
        this.value = value;
    }

    public static TagColor findByOrdinal(int ordinal) {
        return colorMap.getOrDefault(ordinal % colorMap.size(), BLUE);
    }
}
